package testing;

import api.MarketFactory;
import api.betfairAPI.BetfairMarket;
import api.MarketType;
import org.junit.Test;

import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

/**
 * User: Darren
 * Date: 29/01/13
 * Time: 7:58 PM
 */
public class BetfairMarketTest {

    @Test
    public void getRemovedRunnerTest() {
        System.out.println("Executing: testing.BetfairMarketTest.getRemovedRunnerTest");
        BetfairMarket market = (BetfairMarket)new MarketFactory().getMarket(MarketType.BETFAIR_MARKET);
        market.getNewRemovedRunner().setName("0");
        market.getNewRemovedRunner().setName("1");
        market.getNewRemovedRunner().setName("2");
        market.getNewRemovedRunner().setName("3");
        for (int i = 0; i < market.getRemovedRunners().size(); ++i) {
            assertTrue(market.getExistingRemovedRunner(i).get().getName().equals(Integer.toString(i)));
        }
    }

    @Test
    public void getRunnerTest() {
        System.out.println("Executing: testing.BetfairMarketTest.getRunnerTest");
        final String theBest = "Arsenal";
        final String scum = "Man U";
        BetfairMarket market = (BetfairMarket)new MarketFactory().getMarket(MarketType.BETFAIR_MARKET);
        market.getNewRunner(1).setName(theBest);
        market.getNewRunner(2).setName(scum);
        assertTrue(market.getExistingRunner(1).get().getName().equals(theBest));
        assertTrue(market.getExistingRunner(2).get().getName().equals(scum));
        assertNull(market.getExistingRunner(3).orNull());
    }
}
